<div class="tmd-doc">
<p></p>
<h1 class="tmd-header-1">
scope 1
</h1>
<p></p>
<div id="question" class="tmd-base">
<p></p>
<div class="tmd-usual">
What does the following program print?
</div>
<p></p>
<pre class="tmd-code line-numbers">
<code class="language-go">package main

func f(n int) (r int) {
	a, r := n-1, n+1
	if a+a == r {
		c, r := n, n*n
		r = r - c
	}
	return r
}

func main() {
	println(f(3))
}
</code></pre>
</div>
<p></p>
<div class="tmd-usual">
Choices:
</div>
<p></p>
<input type="radio" id="choiceA" name="choice" class="choice">
<input type="radio" id="choiceB" name="choice" class="choice">

<div id="choices">

<ul style="list-style-type:none;">
<li><label for="choiceA">4</label></li>
<li><label for="choiceB">6</label></li>
</ul>

</div><p></p>
<div id="answer" class="tmd-base">
<div class="tmd-usual">
Answer: 4
</div>
<p></p>
<div class="tmd-usual">
Run it on <a href="https://go.dev/play/p/YimtmACsxOP">Go play</a>.
</div>
<p></p>
<div class="tmd-usual">
Key point:
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
The <code class="tmd-code-span">r</code> varialbe declared in the inner block is not a re-declaration of the one (the return result) declared in the function top block. It is totally a new declared variable. So the return result is not modified in the inner block.
</div>
</li>
</ul>
<p></p>
</div>
<p></p>
</div>
